package ClassWork.Work_01;

public class BubbleSort {
    public static void main(String[] args){
        int[] arrs = {5,8,3,1,9};
        System.out.print("冒泡排序前：");
        for(int i = 0; i < arrs.length; i++){
            System.out.print(arrs[i] + " ");
        }
        System.out.println();
        bubblesort(arrs);
    }
    public static void bubblesort(int[] arrs){
        for(int i = 1; i < arrs.length; i++){
            for(int j = 0; j < arrs.length - i; j++){
                if(arrs[j] < arrs[j + 1]){
                    int temp = arrs[j];
                    arrs[j] = arrs[j + 1];
                    arrs[j + 1] = temp;
                }
            }
        }
        System.out.print("冒泡排序后：");
        for(int i = 0; i < arrs.length; i++){
            System.out.print(arrs[i] + " ");
        }
    }
}
